*******************************************************
* Lyle 05 Jan 11: 						              *
*	-this program serves as a base shell for all	  *
*	 stata do files					                  *
*******************************************************


********************************
* Standard Stata Configuration *
********************************
clear all
set mem 999m
capture log close
set logtype text
cap cd "C:\Users\ejm5\Google Drive\2016_Research\Unemployment_MILEX"
cap cd "C:\Users\Jordan.Becker\Desktop\GD\2016_Research\Unemployment_MILEX"
cap cd "\\usnatonetapp01.eur.state.sbu\profiles\beckerjm\Desktop\2016_Research\Unemployment_MILEX"
log using "log\correlates_table2.log", replace


*********************
* Prepare Variables *
*********************
use "dta\2016_02_09_uem", clear
sort ccode year
xtset ccode year


********************
* Analyze the Data *
********************
set more off
sort ccode year
xtset ccode year


*************SUSTAINABILITY*******************************************************************************
*Figure 3a: Bivariate Relationship between Equipment Share and EDA sustainability*
#delimit;
use "dta\2016_02_09_uem", clear;
sort ccode year;
xtset ccode year;
preserve;
keep if eda_sustainability!=. & eda_sustainability<=100;
#delimit;
twoway (lfit eda_sustainability l3.equipment) 
(scatter eda_sustainability l3.equipment, msymbol(diamond) mcolor(navy) msize(medsmall)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(small) margin(medsmall))
legend(rows(2) size(vsmall) position(2) ring(0) label(1 Fitted) label(2 Observed))
title("A: All Country-Years (3-year lag on DV)", size(medlarge));
graph save output\equipment_sustainability_a.gph, replace;
restore;


*Figure 3b: Mean Bivariate Relationship between Equipment Share and EDA sustainability*
#delimit;
preserve;
keep if eda_sustainability!=.;
collapse equipment eda_sustainability, by (countryname);

#delimit;
twoway (lfit eda_sustainability equipment) 
(scatter eda_sustainability equipment, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(countryname)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(off)
title("B: Mean 2006-2014", size(medlarge));

graph save output\equipment_sustainability_b.gph, replace;

#delimit;
graph combine output\equipment_sustainability_a.gph output\equipment_sustainability_b.gph, 
cols(3) ycommon iscale(tiny) imargin(tiny)
title("Equipment (% Defense Spending)", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("EDA sustainability (Sustainable Land Forces/Total Military Personnel)", size(vsmall) position(9) orientation(vertical) margin(medsmall) color(black));
graph save output\equipment_sustainability, replace;
restore;
